package cwinsor.raking.year2014;

public class PropertyVirtualHappiness extends PropertyVirtual {

	public PropertyBase prototype() {
		PropertyBase prototype = new PropertyVirtualHappiness();
		return prototype;
	}

	public Object getValue() {
		return toInteger();
	}

	public Integer toInteger() {

		PROP_E[] curAssign = PROP_E.teamAssignmentList();
		PROP_E[] curPref = PROP_E.curPrefsList();
		Integer totalHappiness = 0;
		for (int i = 0; i < curAssign.length; i++) {

			// if the map is null
			if (propertyMap == null) {
				Msg.fatal(dM + " prop map is null");
			}
			// if the property is not null...
			if (propertyMap.get(curAssign[i]) == null) {
				Msg.note(dM + ": zona temp calculating hapiness - prop " + i +  " is null");
			}

			// if the raker is assigned for this timeslot
			else if (propertyMap.get(curAssign[i]).toInteger() != 0) {
				// add how much they wanted this timeslot to their total happiness
				totalHappiness += propertyMap.get(curPref[i]).toInteger();
			}
		}
		return totalHappiness;
	}

	public String toString() {
		Integer temp = toInteger();
		String tempS = temp.toString();
		return tempS;
	}

	public int compareTo(PropertyBase arg0) {
		return toInteger() - arg0.toInteger();
	}

	// debug
	String dM = this.getClass().getSimpleName();
}
